<template>
  <div>
    <FormPanel
      ref="baseInfo"
      :list="initFormBase"
      :cols="1"
      :labelWidth="140"
      :formType="handleType"
      isSubmitBtn
      @formChange="saveDialog"
    />
  </div>
</template>
<script>
import {dictionary} from '@/utils/dictMixin';
import {putUpdateYJDHSJ,} from '@/api/partsmanage/purchaseManage/purchaseSubmit';
import moment from 'moment';
export default {
  name: "BOEditForm",
  components: {},
  props: {
    handleType: {
      type: String,
      default: 'add'
    },
    pageType: {
      type: String,
      default: ''
    },
    value: {
      default: null
    }
  },
  mixins: [dictionary],
  data() {
    return {
      formData: {},
      initFormBase: this.initFormBaseFun(),
      saveLoading: false,
    };
  },
  mounted() {
    //判断是新增，还是修改
    if (this.handleType == 'edit') {
      this.formData.ids = this.value.map(i => i.id)
    } else {
    }
  },
  created() {
  },
  computed: {},
  methods: {
    //基本表单信息
    initFormBaseFun() {
      return [
        {
          type: 'DATE_TIME',
          label: '预计到货时间',
          fieldName: 'yjdhsj',
          placeholder: '请输入',
          initialValue: '',
          // format: 'yyyy-MM-dd HH:mm:ss',
          rules: [
            {required: false, trigger: 'change', message: '请选择预计到货时间'},
          ],
          minDateTime:moment().format('YYYY-MM-DD')
        },
        {
          type: 'TEXT_AREA',
          label: '跟进结果',
          fieldName: 'bsgjjg',
          placeholder: '请输入',
          initialValue: '',
          // format: 'yyyy-MM-dd HH:mm:ss',
          rules: [
            {required: false, trigger: 'change', message: '请输入跟进结果'},
          ],
        },
        {
          type: 'TEXT_AREA',
          label: '解决途径',
          fieldName: 'bsjjtj',
          placeholder: '请输入',
          initialValue: '',
          // format: 'yyyy-MM-dd HH:mm:ss',
          rules: [
            {required: false, trigger: 'change', message: '请输入解决途径'},
          ],
        },
      ];
    },
    //保存
    async saveDialog(data) {
      this.saveLoading = true;
      this.formData = Object.assign({}, this.formData, data);
      let res = await putUpdateYJDHSJ(this.formData);
      if (res.resultCode === 200) {
        this.$notify.success({title: '提示信息', message: '保存成功!'});
        // 重新加载
        this.closeDialog('refresh');
      }
      this.saveLoading = false;
    },
    //取消操作
    closeDialog(type) {
      this.$emit('close', type);
    }
  }
};
</script>

<style lang="less" scoped>
</style>
